<!doctype html>

<html>

  <head>
    <meta charset="utf-8">
    <title>WASM test with XHR</title>
  </head>

  <body>
    <script>
      var importObject = {
        imports: {
          imported_func: function(arg) {
            console.log(arg);
          }
        }
      };

      request = new XMLHttpRequest();
      request.open('GET', 'simple.wasm');
      request.responseType = 'arraybuffer';
      request.send();

      request.onload = function() {
        var bytes = request.response;
        WebAssembly.instantiate(bytes, importObject).then(function(obj) {
          obj.instance.exports.exported_func();
        });
      };
    </script>
  </body>

</html>
